package com.xbongbong.pro.enums;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

/**
 * 打印场景类型
 *
 * @author hongxiao
 * @date 2021-01-18 16:10
 * @since
 * @version
 */
@Getter
public enum PrintSceneTypeEnum {
    /**
     * 场景类型：0默认通用打印场景，1快递单打印场景，2发票打印场景，3人事打印场景
     */
    DEFAULT(0, "default", "enum.printSceneType.default"),
    EXPRESS(1, "express", "enum.printSceneType.express"),
    INVOICE(2, "invoice", "enum.printSceneType.invoice"),
    PERSONNEL(3, "personnel", "enum.printSceneType.personnel");

    private Integer code;
    private String alias;
    private String name;

    PrintSceneTypeEnum(Integer code, String alias, String name) {
        this.code = code;
        this.alias = alias;
        this.name = name;
    }

    public static PrintSceneTypeEnum getByCode(Integer code) {
        for (PrintSceneTypeEnum cacheCode : values()) {
            if (cacheCode.getCode().equals(code)) {
                return cacheCode;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
}
